package com.qf.fengmimall.order.controller;

import com.qf.fengmimall.order.entity.Orders;
import com.qf.fengmimall.order.service.IOrdersService;
import com.qf.fengmimall.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 订单  前端控制器
 * </p>
 *
 * @author lx
 * @since 2023-02-16
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
@Slf4j
public class OrdersController {

    @Autowired
    private IOrdersService ordersService;

    /**
     * 下单付款
     *
     * @param cids
     * @param order
     * @return
     */
    @RequestMapping("/add")
    public ResultVo add(String cids, @RequestBody Orders order) throws Exception {
        log.debug("接收到的参数cids={0},order={0}", cids, order);
        Map<String, Object> map = ordersService.addOrder(cids, order);
        return ResultVo.ok(map);
    }

    @RequestMapping("/status/{oid}")
    public ResultVo status(@PathVariable("oid") String oid) throws Exception {
        log.debug("接受到的参数为oid={0}", oid);
        String status = ordersService.status(oid);
        return ResultVo.ok(status);

    }


}
